<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" :width="500" :close-on-press-escape="mode != 'show' ? false : true"
			   destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" ref="dialogForm" label-width="100px">
			<el-form-item label="期初库存数量" prop="stock">
				<el-input-number v-model="form.stock" :min="0" placeholder="请输入期初库存数量" style="width: 100%;" clearable></el-input-number>
			</el-form-item>
			<el-form-item label="期初成本价" prop="price">
				<el-input-number v-model="form.price" :min="0" placeholder="请输入期初成本价" style="width: 100%;" clearable></el-input-number>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">确 定</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			titleMap: {
				add: '批量设置',
				edit: '批量设置',
				show: '批量设置'
			},
			visible: false,
			isSaveing: false,
			//表单数据
			form: {
				stock:null,
				price:null
			},
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
		//表单提交方法
		submit() {
			this.isSaveing = true;
			this.$emit('success', this.form)
			this.visible = false;
			this.isSaveing = false;
		},
		//表单注入数据
		setData() {

		}
	}
}
</script>

<style>
</style>
